/**
 * Created by chengxiaolong on 2016/5/31.
 */
package com.invexer.service.baosteel {
import com.invexer.service.linggang.*;
import com.invexer.service.common.InvexerHttpService;

public class BaoSteelHttpService implements IBaoSteelService {
    //private static var logger : Logger = //logger.getLogger(LingGangHttpService);

    private var _httpService:InvexerHttpService;
    private var _productionMode:String;
    private var _config:Object;

    public function BaoSteelHttpService() {
        _httpService = new InvexerHttpService();
    }

    public function getApi(key:String):String{
        return _config.baseUrl[_productionMode] + _config.apis[key];
    }

    public function set productionMode(value:String):void {
        _productionMode = value;
    }

    public function set config(value:Object):void {
        _config = value;
    }

    private function processData(data:Object):Object{
        var jsonString:String = data as String;
        if(!jsonString || jsonString.length==0) return null;

        data = JSON.parse(jsonString);

        return data;
    }

    public function getHangZhouWeatherInfo(successCallback:Function, failCallback:Function):void {
    }

    public function getCashFlowData(successCallback:Function, failCallback:Function):void {
        _httpService.sendGetRequest(getApi("getCashFlowData"), null, function (data:Object):void {
            data = processData(data);
            successCallback(data ? data : null);
        }, failCallback);
    }

    public function getBalance(params:Object, successCallback:Function, failCallback:Function):void {
    }
}
}
